package manage.action;

import m.common.action.ActionMeta;
import m.common.action.RequestMeta;
import m.system.util.JSONMessage;
import manage.model.AdminGroupPower;
import manage.run.ModuleInitRun;
import manage.service.AdminGroupPowerService;

@ActionMeta(name="manage/adminGroupPower")
public class AdminGroupPowerAction extends ManageAction {
	private AdminGroupPower model;
	@RequestMeta(params= {"groupOid"})
	public JSONMessage getAllAdminGroupPower(String groupOid) throws Exception {
		verifyAdminOperPower("manage_system_power");
		return new JSONMessage(0)
				.push("list", ModuleInitRun.getPowerList())
				.push("power",getService(AdminGroupPowerService.class).getPowerMapByGroup(groupOid));
	}
	@RequestMeta(params= {"adminOid","groupOid"})
	public JSONMessage getPower4Admin(String adminOid,String groupOid) throws Exception {
		verifyAdminOperPower("manage_system_power");
		return new JSONMessage(0)
				.push("powers", getService(AdminGroupPowerService.class).getPowerTitleList(adminOid,groupOid));
	}

	public JSONMessage addAdminGroupPower() throws Exception {
		verifyAdminOperPower("manage_system_power");
		getService(AdminGroupPowerService.class).addAdminGroupPower(model);
		return new JSONMessage(0,"添加权限成功");
	}
	public JSONMessage removeAdminGroupPower() throws Exception {
		verifyAdminOperPower("manage_system_power");
		getService(AdminGroupPowerService.class).removeAdminGroupPower(model);
		return new JSONMessage(0,"移除权限成功");
	}

	public AdminGroupPower getModel() {
		return model;
	}

	public void setModel(AdminGroupPower model) {
		this.model = model;
	}

}
